<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	pageContext.setAttribute("ctx", request.getContextPath());	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>組織代碼維護</title>
<link rel="stylesheet"  type="text/css" href="${ctx}/css/default.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/js/jqueryeasyui12/themes/bootstrap/easyui.css" />
<link rel="stylesheet" type="text/css" href="${ctx}/js/jqueryeasyui12/themes/icon.css" />
<script type="text/javascript" src="${ctx}/js/jqueryeasyui12/jquery.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jqueryeasyui12/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx}/js/jqueryeasyui12/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/jquery.form.js"></script>
<style type="text/css">.datagrid-cell, .datagrid-cell-group, .datagrid-header-rownumber, .datagrid-cell-rownumber{-o-text-overflow: ellipsis;text-overflow: ellipsis;}</style>
<script type="text/javascript">
	var ctx = '${ctx}';

	/**
	datagrid增加ToolTip
	*/
	$.extend($.fn.datagrid.methods, {
	    /**
	    * 开打提示功能
	    * @param {} jq
	    * @param {} params 提示消息框的样式
	    * @return {}
	    */
	    doCellTip: function (jq, params) {
	        function showTip(data, td, e) {
	            if ($(td).text() == "")
	                return;
	            data.tooltip.text($(td).text()).css({
	                top: (e.pageY + 10) + 'px',
	                left: (e.pageX + 20) + 'px',
	                'z-index': $.fn.window.defaults.zIndex,
	                display: 'block'
	            });
	        };
	        return jq.each(function () {
	            var grid = $(this);
	            var options = $(this).data('datagrid');
	            if (!options.tooltip) {
	                var panel = grid.datagrid('getPanel').panel('panel');
	                var defaultCls = {
	                    'border': '1px solid #333',
	                    'padding': '2px',
	                    'color': '#333',
	                    'background': '#f7f5d1',
	                    'position': 'absolute',
	                    'max-width': '200px',
	                    'border-radius': '4px',
	                    '-moz-border-radius': '4px',
	                    '-webkit-border-radius': '4px',
	                    'display': 'none'
	                };
	                var tooltip = $("<div id='celltip' style='font-size:9px;'></div>").appendTo('body');
	                tooltip.css($.extend({}, defaultCls, params.cls));
	                options.tooltip = tooltip;
	                panel.find('.datagrid-body').each(function () {
	                    var delegateEle = $(this).find('> div.datagrid-body-inner').length ? $(this).find('> div.datagrid-body-inner')[0] : this;
	                    $(delegateEle).undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove').delegate('td', {
	                        'mouseover': function (e) {
	                            if (params.delay) {
	                                if (options.tipDelayTime)
	                                    clearTimeout(options.tipDelayTime);
	                                var that = this;
	                                options.tipDelayTime = setTimeout(function () {
	                                    showTip(options, that, e);
	                                }, params.delay);
	                            }
	                            else {
	                                showTip(options, this, e);
	                            }
	
	                        },
	                        'mouseout': function (e) {
	                            if (options.tipDelayTime)
	                                clearTimeout(options.tipDelayTime);
	                            options.tooltip.css({
	                                'display': 'none'
	                            });
	                        },
	                        'mousemove': function (e) {
	                            var that = this;
	                            if (options.tipDelayTime)
	                                clearTimeout(options.tipDelayTime);
	                            //showTip(options, this, e);
	                            options.tipDelayTime = setTimeout(function () {
	                                showTip(options, that, e);
	                            }, params.delay);
	                        }
	                    });
	                });
	
	            }
	
	        });
	    },
	    /**
	    * 关闭消息提示功能
	    *
	    * @param {}
	    *            jq
	    * @return {}
	    */
	    cancelCellTip: function (jq) {
	        return jq.each(function () {
	            var data = $(this).data('datagrid');
	            if (data.tooltip) {
	                data.tooltip.remove();
	                data.tooltip = null;
	                var panel = $(this).datagrid('getPanel').panel('panel');
	                panel.find('.datagrid-body').undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove');
	            }
	            if (data.tipDelayTime) {
	                clearTimeout(data.tipDelayTime);
	                data.tipDelayTime = null;
	            }
	        });
	    }
	});
	
	//頁面初始化
    jQuery(document).ready(function(){
        var params={};
		$('#qryOrgGrid').datagrid({
			title:'組織代碼信息',
			nowrap: true,
			onLoadSuccess: function (data) {
                $(this).datagrid('doCellTip', { 'max-width': '700px', 'delay': 500 });
            },
			striped: true,
			fitColumns: false,
			url: ctx+'/org.do?action=orgList',
			remoteSort: false,
		    queryParams:params,
			idField:'orgId',
			singleSelect:true,
			rownumbers:true,
			frozenColumns:[[
                {field:'ck',checkbox:true,width:30},
                {title:'orgId',field:'orgId',width:30,hidden:true},
                {title:'levelId',field:'levelId',width:30,hidden:true},
                {field:'parentId',title:'parentId',width:120,hidden:true},
                {field:'dominate',title:'廠區',width:100,
                	formatter:function(value,rowData,rowIndex) {
						if(rowData.dominate=='ZZK') {
							return "鄭州綜保區";
						} else if(rowData.dominate=='ZZC') {
							return "鄭州加工區";
						} else if(rowData.dominate=='JCX') {
							return "晉城";
						} else if(rowData.dominate=='JYX') {
							return "濟源";
						} else if(rowData.dominate=='LHX') {
							return "龍華";
						} else if(rowData.dominate=='GLX') {
							return "觀瀾";
						} else if(rowData.dominate=='HBX') {
							return "鶴壁";
						}else if(rowData.dominate=='NH') {
							return "內湖";
						} else {
							return rowData.dominate;
						}
			    	}		
                },
                {field:'orgCode',title:'組織代碼',width:150},
			    {field:'orgName',title:'組織名稱',width:100}
			]],
			columns:[[
			    {field:'orgFee',title:'費用代碼',width:120},
			    {field:'levelName',title:'組織層級',width:120},
			    {field:'leaderNo',title:'主管工號',width:120},
			    {field:'leaderName',title:'主管姓名',width:120},
			    {field:'enable',title:'是否有效',width:120,
			    	formatter:function(value,rowData,rowIndex) {
						if(rowData.enable=='1') {
							return "有效";
						} else {
							return "無效";
						}
			    	}		
			    },
			    {field:'parentCode',title:'上級組織代碼',width:120},
			    {field:'parentName',title:'上級組織名稱',width:120},
			    {field:'createName',title:'創建人',width:100},
			    {field:'createTime',title:'創建時間',width:100}
			]],
			pagination:true,
			pageSize:10,
			pageNumber:1,
			pageList:[10,20,30]
		});
		
		//為組織層級賦初始值
	    $.ajax({
			type: "POST",
			url : ctx+'/org.do?action=getOrgLevelList',
			data : params,
			dataType : "json",
			cache : false,
			asyn : false,
			error : function(textStatus, errorThrown) {
				$.messager.alert('系統提示','系統錯誤,請聯繫管理員','error');
			},
			success : function(data, textStatus) {
				var list = data.orgLevelList;
				for(var key in list) {
					var k = parseInt(key);
					var level = list[k];
					$("#levelId").append("<option value=\""+level.levelId+"\">"+level.levelName+"</option>");
				}
			}
		});
		
		//新增/修改組織代碼信息
	    $('#submitOrg').click(function() {	
	    	var validationResult = $("#editForm").form('validate');
          	if(validationResult==false){
          		$.messager.alert('系統提示','請按照規定輸入必填信息!','warning');
          		return;
          	} else {
          		$.messager.confirm('系統提示', '您確定需要提交嗎?', function(r) {
	                if (r) {		              	
		              	var method = $.trim($("#method").val());
		              	var dourl = "";
		               	if(method=='add'){	          	
		                    dourl = ctx+'/org.do?action=addOrg';
		               	} else if(method=='edit'){
		               	 	dourl = ctx+'/org.do?action=editOrg';
		                }
		               	var params={
			               		method : method,	
			               		orgId : $("#orgId").val(),
			               		dominate : $("#dominate").val(),
			               		orgName : $("#orgName").val(),
			               		orgCode : $("#orgCode").val(),
			               		orgFee : $("#orgFee").val(),
			               		levelId : $("#levelId").val(),
			               		leaderNo : $("#leaderNo").val(),
			               		leaderName : $("#leaderName").val(),
			               		parentId : $("#parentId").val(),
			               		enable : $("#enable").val()
		               	};
		               	$.ajax({
		        			type: "POST",
		        			url : dourl,
		        			data : params,
		        			dataType : "json",
		        			cache : false,
		        			asyn : false,
		        			error : function(textStatus, errorThrown) {
		        				$.messager.alert('系統提示','系統錯誤，請聯繫管理員!','error');
		        			},
		        			success : function(data, textStatus) {
		        				var result = data.result;
		        				if(result == "exist") {
		        					$.messager.alert('系統提示','組織代碼已存在，請修改!','warning');
		        				} else if(result == "highLevel") {
		        					$.messager.alert('系統提示','當前組織層級不能高於或等於上級組織層級!','warning');
		        				} else if(result == "success") {
		        					if(method=='add'){	          	
		        						$.messager.alert('系統提示','新增成功!','info');
		        						$("#optionWin").window('close');
		        						queryOrgByParams();
		    		               	} else if(method=='edit'){
		    		               		$.messager.alert('系統提示','修改成功!','info');
		    		               		$("#optionWin").window('close');
		    		               		queryOrgByParams();
		    		                }
		        				} else {
		        					$.messager.alert('系統提示','系統錯誤，請聯繫管理員!','error');
		        				}
		        				
		        			}
		        		});
	         	    }
       		   });
          	}
	    });
	    $('#cancelOrg').click(function() {
			$("#optionWin").window('close');
		});
	    
	    //選擇父級組織
	    $('#chooseParent').click(function() {
	    	var optionWinParent = $("#optionWinParent");
			optionWinParent.find("input").val("");
			optionWinParent.find("select").val("");
			if (optionWinParent.is(':visible')){
				;
			}else{
				optionWinParent.slideDown();//显示 
			} 
			optionWinParent.window('open');
			
	    	var params={
	    			"f_enable" : "1"
	    	};
			$('#qryOrgParentGrid').datagrid({
				//title:'組織代碼信息',
				nowrap: true,
				onLoadSuccess: function (data) {
	                $(this).datagrid('doCellTip', { 'max-width': '700px', 'delay': 500 });
	            },
				striped: true,
				fitColumns: false,
				url: ctx+'/org.do?action=orgList',
				remoteSort: false,
			    queryParams:params,
				idField:'orgId',
				singleSelect:true,
				rownumbers:true,
				frozenColumns:[[
	                {field:'ck',checkbox:true,width:30},
	                {title:'orgId',field:'orgId',width:30,hidden:true},
	                {title:'levelId',field:'levelId',width:30,hidden:true},
	                {field:'parentId',title:'parentId',width:120,hidden:true},
	                {field:'dominate',title:'廠區',width:100},
	                {field:'orgCode',title:'組織代碼',width:150},
				    {field:'orgName',title:'組織名稱',width:100}
				]],
				columns:[[
				    {field:'orgFee',title:'費用代碼',width:120},
				    {field:'levelName',title:'組織層級',width:120},
				    {field:'leaderNo',title:'主管工號',width:120},
				    {field:'leaderName',title:'主管姓名',width:120},
				    {field:'enable',title:'是否有效',width:120,
				    	formatter:function(value,rowData,rowIndex) {
							if(rowData.enable=='1') {
								return "有效";
							} else {
								return "無效";
							}
				    	}		
				    },
				    {field:'parentCode',title:'上級組織代碼',width:120},
				    {field:'parentName',title:'上級組織名稱',width:120},
				    {field:'createName',title:'創建人',width:100},
				    {field:'createTime',title:'創建時間',width:100}
				]],
				pagination:true,
				pageSize:10,
				pageNumber:1,
				pageList:[10,20,30]
			});
			
			$('#qryOrgParentGrid').datagrid('unselectAll');
	    });
	    $('#submitOrgParent').click(function() {
	    	var selected = $('#qryOrgParentGrid').datagrid('getSelected');
	    	if(selected){ 
	    		$("#parentId").val(selected.orgId);
		    	$("#parentCode").val(selected.orgCode);
		    	$("#parentName").val(selected.orgName);
		    	$("#optionWinParent").window('close');
	    	} else {
	    		$.messager.alert('系統提示','請先選擇一個組織!','warning');
	    	}
	    });
	    $('#cancelOrgParent').click(function() {
			$("#optionWinParent").window('close');
		});
	    $('#clearParent').click(function() {
	    	$("#parentId").val("");
	    	$("#parentCode").val("");
	    	$("#parentName").val("");
		});
	    
	    //導入
		$('#import').click(function() {
			//var resultTable = $("#resultTable").remove();
			var fileName = $("#file").val();
			var ext = fileName.substring(fileName.lastIndexOf("."), fileName.length).toLowerCase();
			$("#ext").val(ext);
			
			if (ext == '.xls' || ext == ".xlsx") {//这里限定上传文件文件类型
				$.messager.confirm('系統提示', '您確定需要導入嗎？', function(r) {
		            if (r) {
		            	$("#importForm").ajaxSubmit({
		    				type: "post",
		    				url:ctx +'/org.do?action=importext',
		    				data: $("#importForm").serialize(),
		    				dataType: "text",
		    			    success: function(data){
		    			    	$.messager.alert('系統提示','數據導入完成!','info');
		    			    	$("#result").html("");
		    			    	var strs = new Array(); //定义一数组 
	   							strs = data.split("|"); //字符分割 
	   							for ( var i = 1; i < strs.length; i++ ){ 
	   								if(i < strs.length - 3){
	   									var subStrs = new Array();
	   	   								subStrs = strs[i].split("&");
	   	   								if(subStrs[1] == "code")
	   	   									$("#result").append("<tr><td align=\"center\" width=\"20px\">"+i+"</td><td width=\"80px\">第 "+subStrs[0]+" 筆數據</td><td align=\"left\">組織代碼已存在</td></tr>");
	   	   								else if(subStrs[1] == "caption")
	   	   									$("#result").append("<tr><td align=\"center\" width=\"20px\">"+i+"</td><td width=\"80px\">第 "+subStrs[0]+" 筆數據</td><td align=\"left\">組織層級不存在</td></tr>");
	   	   								else if(subStrs[1] == "data")
	   	   									$("#result").append("<tr><td align=\"center\" width=\"20px\">"+i+"</td><td width=\"80px\">第 "+subStrs[0]+" 筆數據</td><td align=\"left\">數據不規範，請參考上方《文件參數說明》</td></tr>");
	   								}else{
	   									$("#accountRes").css('display','block');
	   									if(i == strs.length - 1)
	   										$("#failRes").html(strs[i]);
	   									if(i == strs.length - 2)
	   										$("#successRes").html(strs[i]);
	   									if(i == strs.length - 3)
	   										$("#totalRes").html(strs[i]);
	   								}
	   								$('#qryOrgGrid').datagrid('reload');
	   							} 
		    				}
		    			});
		            }
				});
			} else {
			 	$.messager.alert('錯誤提示',"上传文件应该是.xls或.xlsx后缀而不应该是" + ext + ", 请重新选择文件",'info');
			}
			
		});
	    //清空上傳結果的Table數據
	   $('#optionWinImport').window({
	    	onClose : function(){
	    		$("#accountRes").css('display','none');
	    		$("#result").empty();
	    	}
	    }); 
    });
	
	//查詢
	function queryOrgByParams() {
		var param={};
		var fields=$('#tbFormOrgId').serializeArray();
		$.each(fields,function(i,field){
			if(field.value!=""){			
					param[field.name]=field.value;
			}
		});
		$('#qryOrgGrid').datagrid('load',param);
		$('#qryOrgGrid').datagrid('unselectAll');
	}
	function queryOrgParentByParams() {
		var param={};
		var fields=$('#tbFormOrgParentId').serializeArray();
		$.each(fields,function(i,field){
			if(field.value!=""){			
					param[field.name]=field.value;
			}
		});
		$('#qryOrgParentGrid').datagrid('load',param);
		$('#qryOrgParentGrid').datagrid('unselectAll');
	}
	function reset() {
		$("#f_orgCode").val("");
		$("#f_orgName").val("");
		$("#f_enable").val("");
	}
	function resetParent() {
		$("#s_orgCode").val("");
		$("#s_orgName").val("");
		$("#s_enable").val("");
	}
	
	//新增
	function addRowOpen(){
		var optionWin = $("#optionWin");
		optionWin.find("input").val("");
		optionWin.find("select").val("");
		$("#method").val('add');
		if (optionWin.is(':visible')){
			;
		}else{
			optionWin.slideDown();//显示 
		} 
		optionWin.window('open');
	}
	
	function editRowOpen(){
		var optionWin = $("#optionWin");
	    optionWin.find("input").val("");
	    optionWin.find("select").val("");
		var selected = $('#qryOrgGrid').datagrid('getSelected');
		if(selected){
			var optionWin = $("#optionWin");
		    if (optionWin.is(':visible')){
			    ;
		    }else{
		        optionWin.slideDown();//显示 
		    }
			$('#method').val('edit');
			optionWin.find("#orgId").val(selected.orgId);
			optionWin.find("#dominate").val(selected.dominate);
			optionWin.find("#orgName").val(selected.orgName);
			optionWin.find("#orgCode").val(selected.orgCode);
			optionWin.find("#orgFee").val(selected.orgFee);
			optionWin.find("#levelId").val(selected.levelId);
			optionWin.find("#leaderNo").val(selected.leaderNo);
			optionWin.find("#leaderName").val(selected.leaderName);
			optionWin.find("#parentId").val(selected.parentId);
			optionWin.find("#parentCode").val(selected.parentCode);
			optionWin.find("#parentName").val(selected.parentName);
			optionWin.find("#enable").val(selected.enable);
		    optionWin.window('open');
		}else{
			$.messager.alert('系統提示','請先選擇一筆資料再進行修改!','warning');
		}
	}
	
	//通過工號帶出姓名
	function quaryUserName() {
		var leaderNo = $("#leaderNo").val();
		$("#leaderName").val("");
		if(leaderNo!="") {
			var dourl = ctx+'/org.do?action=getAdminUserName';
           	var params={
           			leaderNo : leaderNo
           	};
			$.ajax({
				type: "POST",
				url : dourl,
				data : params,
				dataType : "json",
				cache : false,
				asyn : false,
				error : function(textStatus, errorThrown) {
					$.messager.alert('系統提示','系統錯誤，請聯繫管理員!','error');
				},
				success : function(data, textStatus) {
					var result = data.result;
					if(result == "success") {
						$("#leaderName").val(data.leaderName);
					} else {
						$.messager.alert('系統提示','該主管工號不存在或已停用','warning');
					}
				}
			});
		}
	}
	
	//刪除
	function deleteRow() {
		var selected = $('#qryOrgGrid').datagrid('getSelected');
		var index = $('#qryOrgGrid').datagrid('getRowIndex', selected);
    	if(selected){ 
    		$.messager.confirm('系統提示', '您確定要刪除該組織信息嗎?', function(r) {
	        	if (r) {
	        		var dourl = ctx+'/org.do?action=delOrg';
	               	var params={
	               			orgId : selected.orgId
	               	};
	    			$.ajax({
	    				type: "POST",
	    				url : dourl,
	    				data : params,
	    				dataType : "json",
	    				cache : false,
	    				asyn : true,
	    				error : function(textStatus, errorThrown) {
	    					$.messager.alert('系統提示','系統錯誤，請聯繫管理員!','error');
	    				},
	    				success : function(data, textStatus) {
	    					var result = data.result;
	    					if(result == "success") {
	    						$("#qryOrgGrid").datagrid('deleteRow', index);
	    						$.messager.alert('系統提示','刪除成功!','info');
	    					} else {
	    						$.messager.alert('系統提示','系統錯誤，請聯繫管理員!','error');
	    					}
	    				}
	    			});
	        	}
    		});
    	} else {
    		$.messager.alert('系統提示','請先選擇一筆資料再進行刪除!','warning');
    	}
	}
	
	//樹形瀏覽
	function treeScan(){
		var optionWin = $("#optionOrgScanTreeWin");
		if (optionWin.is(':visible')){
			;
		}else{
			optionWin.slideDown();//显示 
		}
		
		var dourl = ctx+'/org.do?action=orgScanTree';
       	$('#orgScanTree').tree({    
    		url: dourl,
    		lines:true,
    		loadFilter: function(data){   
    			return data.data;      
    		}     
    	}); 
		
		optionWin.window('open');
	}
	//導出方法
	function exportRow(){
		
		$("<div class=\"datagrid-mask\"></div>").css({ display: "block", width: "100%", height: $(window).height() }).appendTo("body");  
	    $("<div class=\"datagrid-mask-msg\"></div>").html("<font style=\"font-family:Arial,Console,Verdana,Courier New;font-size:13px;\">請稍後，正在導出數據...</font>").appendTo("body").css({ display: "block", left: ($(document.body).outerWidth(true) - 400) / 2, top: ($(window).height() - 45) / 2 });
		
	    $('#e_orgCode').val($("#f_orgCode").val());
		$('#e_orgName').val($('#f_orgName').val());
		$('#e_enable').val($("#f_enable").val());
		//給form的action 賦值
		var form = document.forms[0];
		form.submit();
	    
		$(".datagrid-mask").remove();
		$(".datagrid-mask-msg").remove();
		
	}
	//導入方法
	function importRow(){
		var optionWin = $("#optionWinImport");
		if (optionWin.is(':visible')){
			;
		}else{
			optionWin.slideDown();//显示 
		}
		optionWin.find("input").val("");
		optionWin.window('open');
	}
</script>
</head>
<body>
	<form action="${ctx}/org.do?action=export" method="post" id="exportForm" >
  		<input type="hidden" name="orgCode" id="e_orgCode" value=""/>
  		<input type="hidden" name="orgName" id="e_orgName" value=""/>
  		<input type="hidden" name="enable" id="e_enable" value=""/>
  	</form>
	<div style="width:98%">
    	<table id="qryOrgGrid" toolbar="#tbOrg"></table>
    	<div id="tbOrg">
			<form action="" id="tbFormOrgId" style="margin:0px;margin-bottom:10px;">
				<table width="100%" id="tableShowOrg">
					<tr>
						<td width="60%" style="white-space:nowrap;">
							<a href="#" id="btnadd" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addRowOpen()">新增</a>
							<a href="#" id="btnedit" class=	"easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editRowOpen()">修改</a>
							<!-- <a href="#" id="btndel" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteRow()">刪除</a> -->
							<a href="#" id="btnimport" class="easyui-linkbutton" iconCls="icon-in" plain="true" onclick="importRow()">Excel導入</a>
							<a href="#" id="btnexport" class="easyui-linkbutton" iconCls="icon-redo" plain="true" onclick="exportRow()">Excel導出</a>
							<a href="#" id="btntreescan" class="easyui-linkbutton" iconCls="icon-filter" plain="true" onclick="treeScan()">樹形瀏覽</a>
						</td>
						<td width="40%" style="white-space:nowrap;padding-right:20px" align="right">
		                                                             組織代碼：<input  name="f_orgCode" id="f_orgCode" size="8"  type="text"/>
		                                                             組織名稱：<input  name="f_orgName" id="f_orgName" size="8"    type="text"/>
		          	                         是否有效：<select name="f_enable" id="f_enable" >
									<option value=""></option>
									<option value="1">有效</option>
									<option value="0">無效</option>
								  </select>
							<a href="#" id="btnreset" class="easyui-linkbutton" iconCls="icon-sync" plain="true" onclick="reset()">重置</a>
							<a class="easyui-linkbutton" iconCls="icon-search" plain="true" href="#" onclick="queryOrgByParams()">查询</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
		
		<div id="optionWinParent" class="easyui-window" title="選擇上級組織" closed="true" closable="true" modal="true"  
	     collapsible="false" minimizable="false" maximizable="false" draggable="true" resizable="false"
	     style="width:1000px;height:450px;padding:5px;left:60px;top:50px;background: #fafafa;display:none" align="center">
	     	<div style="width: 100%;height: 100%;overflow:auto;">
				<table id="qryOrgParentGrid" toolbar="#tbOrgParent"></table>
		    	<div id="tbOrgParent">
					<form action="" id="tbFormOrgParentId" style="margin:0px;margin-bottom:10px;">
						<table width="100%" id="tableShowOrgParent">
							<tr>
								<td width="40%" style="white-space:nowrap;padding-right:20px" align="right">
				                                                             組織代碼：<input  name="f_orgCode" id="s_orgCode" size="8"  type="text"/>
				                                                             組織名稱：<input  name="f_orgName" id="s_orgName" size="8"    type="text"/>
				          	               <input  name="f_enable" id="s_enable" size="8"    type="hidden" value="1"/>
									<a href="#" id="btnreset" class="easyui-linkbutton" iconCls="icon-sync" plain="true" onclick="resetParent()">重置</a>
									<a class="easyui-linkbutton" iconCls="icon-search" plain="true" href="#" onclick="queryOrgParentByParams()">查询</a>
								</td>
							</tr>
						</table>
					</form>
				</div>
				<div style="padding:5px;text-align:center;">
					<a id="submitOrgParent" href="#" class="easyui-linkbutton" icon="icon-ok">確定</a>
					&nbsp;&nbsp;&nbsp;
					<a id="cancelOrgParent" href="#" class="easyui-linkbutton" icon="icon-cancel">取消</a>
				</div>
			</div>
		</div>
		
		<div id="optionWin" class="easyui-window" title="組織代碼信息編輯" closed="true" closable="true" modal="true"  
	     collapsible="false" minimizable="false" maximizable="false" draggable="true" resizable="false"
	     style="width:500px;height:450px;padding:5px;left:60px;top:50px;background: #fafafa;display:none" align="center">
	     	<div style="width: 100%;height: 100%;overflow:auto;">
	     		<form id="editForm" name="editForm" action="" method="post">	
				<br>
				<input type="hidden" id="orgId" name="orgId"/>
				<input type="hidden" id="parentId" name="parentId">
				<input type="hidden" id="method"/>
	        	<table class="formTbl" style="font-size:13px">
	        	<tbody align="left">
					<tr>
						<th align="right">廠區:</th>
						<td>
							<select id="dominate" name="dominate" style="width: 150px">
								<option value=""></option>
								<option value="ZZK">鄭州綜保區</option>
								<option value="ZZC">鄭州加工區</option>
								<option value="JYX">濟源</option>
								<option value="JCX">晉城</option>
								<option value="LHX">龍華</option>
								<option value="GLX">觀瀾</option>
								<option value="HBX">鶴壁</option>
								<option value="NH">內湖</option>
							</select>
						    <font color="red">*</font>
						</td>
					</tr>
					<tr>
						<th align="right">組織代碼:</th>
						<td colspan="3">
							<input type="text" id="orgCode" name="orgCode" class="easyui-validatebox" required="true" maxLength="10" style="width: 150px">
						    <font color="red">*</font>
						</td>
					</tr>  
					<tr>
						<th align="right">組織名稱:</th>
						<td colspan="3">
							<input type="text" id="orgName" name="orgName" class="easyui-validatebox" required="true" maxLength="20" style="width: 150px">
						    <font color="red">*</font>
						</td>
					</tr> 
					<tr>
						<th align="right">費用代碼:</th>
						<td>
						    <input type="text" id="orgFee" name="orgFee" class="easyui-validatebox" required="true" maxLength="10" style="width: 150px">
						</td>
					</tr>
					<tr>
						<th align="right">組織層級:</th>
						<td>
							<select id="levelId" name="levelId" style="width: 150px">
								<option value=""></option>
							</select>
							<font color="red">*</font>
						</td>
					</tr>
					<tr>
						<th align="right">主管工號:</th>
						<td>
						    <input type="text" id="leaderNo" name="leaderNo" class="easyui-validatebox" required="true" onblur="quaryUserName()" style="width: 150px">
						</td>
					</tr>
					<tr>
						<th align="right">主管姓名:</th>
						<td>
						    <input type="text" id="leaderName" name="leaderName" class="easyui-validatebox" required="true" readonly="readonly" style="width: 150px">
						    <font color="red">*</font>
						</td>
					</tr>
					<tr>
						<th align="right">上級組織代碼:</th>
						<td>
						    <input type="text" id="parentCode" name="parentCode" class="easyui-validatebox" readonly="readonly" style="width: 150px">
						    <a id="chooseParent" href="#" class="easyui-linkbutton">選擇</a>&nbsp;
						    <a id="clearParent" href="#" class="easyui-linkbutton">清除</a>
						</td>
					</tr>
					<tr>
						<th align="right">上級組織:</th>
						<td>
						    <input type="text" id="parentName" name="parentName" class="easyui-validatebox" readonly="readonly" style="width: 150px">
						    <font color="red">*</font>
						</td>
					</tr>
					<tr>
						<th align="right">是否有效:</th>
						<td>
							<select id="enable" name="enable" class="easyui-validatebox" style="width: 150px">
								<option value=""></option>
								<option value="1">有效</option>
								<option value="0">無效</option>
							</select>
						    <font color="red">*</font>
						</td>
					</tr>
					</tbody>
				</table>
				<div style="padding:5px;text-align:center;">
					<a id="submitOrg" href="#" class="easyui-linkbutton" icon="icon-ok">保存</a>
					&nbsp;&nbsp;&nbsp;
					<a id="cancelOrg" href="#" class="easyui-linkbutton" icon="icon-cancel">取消</a>
				</div>
				</form>
			</div>
		</div> 
		
		<div id="optionOrgScanTreeWin" class="easyui-window" title="樹形瀏覽" closed="true" closable="true" modal="true"  
	     collapsible="false" minimizable="false" maximizable="false" draggable="true" resizable="false"
	     style="width:500px;height:450px;padding:5px;left:60px;top:50px;background: #fafafa;display:none">
	     	<div style="width: 100%;height: 100%;overflow:auto;">
	     	<br/>
	     	<ul id="orgScanTree"></ul>
	     	</div>
	    </div>
	    
		<!-- 導入組織信息 -->
		<div id="optionWinImport" class="easyui-window" title="組織信息信息導入" closed="true" modal="true" 
	     collapsible="false" minimizable="false" maximizable="false" draggable="true" resizable="false"
	     style="width:650px;height:500px;padding:5px;left:100px;top:30px;background: #fafafa;display:none" align="center">		
		<form id="importForm" name="importForm" action="${ctx}/org.do?action=importext" method="post" enctype="multipart/form-data">
			<div align="left" style="padding-bottom: 5px;"><span style="font-weight: bold;font-size: 14px;">文件參數說明：</span></div>
			<table width="100%" border="1">
				<tr>
					<td align="center" width="20px">1</td>
					<td width="80px">廠區</td>
					<td align="left">
						<span>需填寫廠區代碼，例如：<font color="red">鄭州綜保區：ZZK、鄭州加工區：ZZC、濟源：JYX、晉城：JCX、龍華：LHX、觀瀾：GLX、鶴壁：HBX</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">2</td>
					<td>組織代碼</td>
					<td align="left">
						<span>填寫說明，例如：<font color="red">TOT11400,TOT11467</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">3</td>
					<td>組織名稱</td>
					<td align="left">
						<span>填寫說明，例如：<font color="red">系統規劃。。。。。</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">4</td>
					<td>費用代碼</td>
					<td align="left">
						<span>填寫說明，例如：<font color="red">TOT11400,TOT11467</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">5</td>
					<td>組織層級</td>
					<td align="left">
						<span>填寫所屬組織層級名稱，例如：<font color="red">系統規劃。。。。。</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">6</td>
					<td>主管工號</td>
					<td align="left">
						<span>填寫說明，例如：<font color="red">H2604622，F464312</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">7</td>
					<td>主管姓名</td>
					<td align="left">
						<span>填寫說明，例如：<font color="red">張三，李四</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">8</td>
					<td>是否有效</td>
					<td align="left">
						<span>需填寫是否有效代碼，例如：<font color="red">0：無效，1：有效</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">9</td>
					<td>上級組織代碼</td>
					<td align="left">
						<span>填寫說明，例如：<font color="red">TOT000,TOT424</font></span>
					</td>
				</tr>
				<tr>
					<td align="center">10</td>
					<td>上級組織</td>
					<td align="left">
						<span>填寫所屬組織名稱，例如：<font color="red">系統規劃，企劃 </font></span>
					</td>
				</tr>
			</table>
			<div align="left" style="padding-bottom:5px;padding-top:10px;">
				<span style="font-weight: bold;font-size: 14px;float:left;padding-top:5px;">選擇文件導入：</span>
				<table>
					<tr>
						<td>
							<input id="file" type="file" name="file" style="width:350px" accept=".xls,.xlsx">
							<input type="hidden" name="ext" id="ext"/>
						</td>
						<td align="left"><a id="import" href="#" class="easyui-linkbutton" style="width:80px;">上傳并導入</a></td>
					</tr>
				</table>
			</div>
			<div align="left" style="padding-bottom: 5px;padding-top: 5px;"><span style="font-weight: bold;font-size: 14px;">文件導入模板：</span><a id="btn" href="${ctx}/org.do?action=download" style="width:100px;">模板下載</a></div>
			<div align="left" style="padding-bottom: 5px;padding-top: 5px;"><span style="font-weight: bold;font-size: 14px;">文件導入結果：</span><span id="accountRes" style="font-weight: bold;font-size: 14px;display: none;">共 <font color="red" id="totalRes">0</font> 筆數據，成功 <font color="red" id="successRes">0</font> 筆，失敗 <font color="red" id="failRes">0</font> 筆。</span></div>
			<table width="100%" border="1" id="result">
				
			</table>
		</form>
	</div>
	</div>
</body>
</html>